package correct.day21;

import java.util.Scanner;
import java.util.TreeSet;

public class Test2 {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        TreeSet<Integer> set = new TreeSet<>();
        int x;
        while(n-- != 0)
        {
            x = in.nextInt();
            set.add(x);
        }
        while(m-- != 0)
        {
            x = in.nextInt();
            set.add(x);
        }
        System.out.println(set.size());
        for(int a : set)
        {
            System.out.print(a + " ");
        }
    }

}
